<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/11/23
 * Time: 13:25
 */
namespace hotel\modules\apiadmin\controllers;

use hotel\common\models\QuestionType;
use hotel\common\utils\Tool;
use \Yii;

class QuestionTypeController extends CoreController
{


    /**
     * @return string
     */
    public function actionList()
    {
        $post = Yii::$app->request->post();
        $res = QuestionType::lists($post,$this->appid);
        return Tool::showRes([0, '获取成功'], $res);
    }

    /**
     * @return string
     */
    public function actionAdd()
    {
        $post = Yii::$app->request->post();
        QuestionType::setData($post,$this->appid);
        return Tool::showRes([0, '操作成功']);
    }

    /**
     * @return string
     */
    public function actionEdit()
    {
        $post = Yii::$app->request->post();
        QuestionType::updateData($post);
        return Tool::showRes([0, '操作成功']);
    }


    /**
     * @return string
     */
    public function actionDel()
    {
        $post = Yii::$app->request->post();
        $ids = $post['ids'];
        if (empty($ids)) return Tool::showRes([400, '参数有误']);
        $ids_arr = explode(',', $ids);
        if (!$res = QuestionType::deleteAll(['in', 'id', $ids_arr])) {
            return Tool::showRes([400, '删除失败']);
        } else {
            return Tool::showRes([0, '删除成功']);
        }
    }


}